package com.laiketui.order.controller;

import com.laiketui.core.domain.Result;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.order.entity.agreement.OrderAgreement;
import com.laiketui.order.service.OrderAgreementService;
import com.laiketui.root.annotation.HttpApiMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单服务协议
 */
@RestController
public class OrderAgreementController {

    @Autowired
    private OrderAgreementService orderAgreementService;

    @PostMapping("getOrderAgreementInfo")
    @HttpApiMethod(urlMapping = {"app.orderV2.getOrderAgreementInfo"})
    public Result getOrderAgreementInfo(String orderParentId){
        try{
            OrderAgreement orderAgreementInfo = orderAgreementService.getOrderAgreementInfo(orderParentId);
            return Result.success(orderAgreementInfo);
        }catch (LaiKeAPIException e){
            return Result.error(e.getCode(),e.getMessage());
        }
    }

}
